home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pine / osdep / bld_path.dos < prev    next >
Text File  |  1996-04-26  |  1KB  |  58 lines

  1. /*----------------------------------------------------------------------
  2.       Paste together two pieces of a file name path
  3.  
  4.   Args: pathbuf      -- Put the result here
  5.         first_part   -- of path name
  6.         second_part  -- of path name
  7.  
  8.  Result: New path is in pathbuf.  No check is made for overflow.
  9.  
  10. BUGS:  This is a first stab at dealing with fs naming dependencies, and others 
  11. still exist.
  12.   ----*/
  13. void
  14. build_path(pathbuf, first_part, second_part)
  15.     char *pathbuf, *first_part, *second_part;
  16. {
  17.     register int i;
  18.  
  19.     if(!first_part){
  20.     strcpy(pathbuf, second_part);
  21.     return;
  22.     }
  23.  
  24.     for(i = 0; first_part[i]; i++)
  25.       *pathbuf++ = first_part[i];
  26.  
  27.     if(i && first_part[i-1] == '\\'){        /* first part ended with \  */
  28.         if(*second_part == '\\')        /* and second starts with \ */
  29.       second_part++;            /* else just append second  */
  30.     }
  31.     else if(*second_part != '\\')        /* no slash at all, so      */
  32.       *pathbuf++ = '\\';            /* insert one...        */
  33.  
  34.     while(*second_part)
  35.       *pathbuf++ = *second_part++;
  36.  
  37.     *pathbuf = '\0';
  38. }
  39.  
  40.  
  41. /*----------------------------------------------------------------------
  42.   Test to see if the given file path is absolute
  43.  
  44.   Args: file -- file path to test
  45.  
  46.  Result: TRUE if absolute, FALSE otw
  47.  
  48.   ----*/
  49. int
  50. is_absolute_path(path)
  51.     char *path;
  52. {
  53.     return(path && (*path == '\\'
  54.             || (isalpha((unsigned char)path[0]) && path[1] == ':')));
  55. }
  56.  
  57.  
  58.